import pandas as pd
import hashlib
 
# 加载Excel文件 
file_path = "data.xlsx" 
df = pd.read_excel(file_path) 
 
# 初始化计数器
a_mismatch_count = 0
b_mismatch_count = 0
 
# 遍历每一行数据
for index, row in df.iterrows(): 
    # 计算A列的校验和
    a_checksum_calculated = hashlib.sha256(str(row['A列']).encode('utf-8')).hexdigest()
    if a_checksum_calculated != str(row['A列校验和']):
        a_mismatch_count += 1
 
    # 计算B列的校验和
    b_checksum_calculated = hashlib.sha256(str(row['B列']).encode('utf-8')).hexdigest()
    if b_checksum_calculated != str(row['B列校验和']):
        b_mismatch_count += 1
 
# 输出结果
result = f"A列-{a_mismatch_count};B列-{b_mismatch_count}"
print("校验结果:", result)
 
# 计算MD5值
md5_value = hashlib.md5(result.encode('utf-8')).hexdigest() 
print("MD5值:", md5_value)
